<style>
    #content #valueSearch {
        padding: 10px;
    }
    #content #keySearch {
        width: 150px;
        padding: 9px;
    }
</style>
<div class="onecolumn">
    <div class="header">
        <span style="color: red; text-align: center; font-weight: bold;">Tìm kiếm tài liệu</span>
    </div>
    <br class="clear"/>
    <div id="content" style="margin-bottom: 20px;">
        <?php
        $form = $this->form;
        $form->setAttribute('action', $this->url('search-document/default', array('action' => 'index',)));
        $form->prepare();
        echo $this->form()->openTag($form);
        ?>
        <p style="float:left; margin-right: 10px;">
            <?php
            echo $this->formRow($form->get('keySearch'));
            ?>
        </p>
        <p style="float: left; margin-right: 10px;">
            <?php
            echo $this->formInput($form->get('valueSearch'));
            ?>
        </p>
        <p>
            <?php
            echo $this->formInput($form->get('search'));
            ?>

        </p>   
        <div class="viewMessae" style="text-align: center">
            <?php
            if (isset($myMessage)) {
                foreach ($myMessage as $key => $message) {
                    if ($message == "inputError")
                        echo '<span style="color:red;font-weight:bold;float:right;margin-right:550px;margin-top:10px;">Bạn chưa chọn kiểu tìm kiếm</span><br/>';
                    if ($message == "notFoundResult")
                        echo '<span style="color:red;font-weight:bold;float:right;margin-right:550px;margin-top:10px;">Không tìm thấy kết quả nào</span><br/>';
                }
            }
            ?>
        </div>
        <?php
        echo $this->form()->closeTag($form);
        ?>
    </div>
</div>
<?php if (isset($paginator) && $paginator != null) : ?>
    <div class="onecolumn">
        <div class="header">
            <span style="color: red;">Danh sách tài liệu tìm được</span>
        </div>
        <br class="clear"/>
        <div class="content">
            <form id="form_data" name="form_data" action="" method="post">
                <table class="data" width="100%" cellpadding="0" cellspacing="0">
                    <thead>
                        <tr>
                            <th>
                                <input type="checkbox" id="check_all" name="check_all"/>
                            </th>
                            <th style="width:10%">Mã tài liệu</th>
                            <th style="width:25%">Tên tài liêu</th>
                            <th style="width:15%">Tên tác giả</th>
                            <th style="width:10%">Vị trí</th>
                            <th style="width:10%">Năm xuất bản</th>
                            <th style="width:15%">Nhà xuất bản</th>
                            <th style="width:7%">Người tạo</th>
                            <th style="width:8%">Thao tác</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($paginator as $row) : ?>
                            <tr>
                                <td>
                                    <input type="checkbox"/>
                                </td>
                                <td>
                                    <a href="<?php echo $this->url('cataloging-document/default', array('action' => 'detailDocument', 'id' => $row->bookBarcode)) ?>"> <?php echo $this->escapeHtml($row->bookBarcode); ?></a>
                                </td>
                                <td><?php echo $this->escapeHtml($row->title); ?></td>
                                <td>
                                    <?php
                                    foreach ($allAuthor[$row->bookBarcode] as $author) {
                                        echo $this->escapeHtml($author) . "<br/>";
                                    }
                                    ?>
                                </td>
                                <td><?php echo $this->escapeHtml($row->location); ?></td>
                                <td>
                                    <?php
                                    $date = explode('-', $row->yearOfPublish);
                                    echo $date[2] . '-' . $date[1] . '-' . $date[0];
                                    ?>
                                </td>
                                <td><?php echo $this->escapeHtml($row->publisher); ?></td>
                                <td><?php echo $this->escapeHtml($row->personCreated); ?></td>
                                <td>
                                    <a href="<?php echo $this->url('cataloging-document/default', array('action' => 'editDocument', 'id' => $row->bookBarcode)) ?>"><img src=<?php echo $this->basePath() . '/img/icon_edit.png' ?> alt="edit" class="help" title="Chỉnh sửa"/></a>
                                    <a href="<?php echo $this->url('cataloging-document/default', array('action' => 'deleteDocument', 'id' => $row->bookBarcode)) ?>" style="margin-left: 30px;"><img src=<?php echo $this->basePath() . '/img/delete.png' ?> alt="delete" class="help" title="Xóa tài liệu này"/></a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
                <?php
                // add at the end of the file after the table
                echo $this->paginationControl(
                        // the paginator object
                        $this->paginator,
                        // the scrolling style; see http://zf2.readthedocs.org/en/release-2.1.4/modules/zend.paginator.usage.html#rendering-pages-with-view-scripts
                        'sliding',
                        // the partial to use to render the control
                        array('partial/paginator.phtml', 'Admin'),
                        // the route to link to when a user clicks a control link
                        array(
                    'route' => 'search-document',
                        )
                );
                ?>
            </form>

        </div>
    </div>
<?php endif; ?>